Actually use absolute paths for crates.io crates
authorAlex Crichton <alex@alexcrichton.com>
Thu, 15 Jan 2015 20:17:18 +0000 (12:17 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 16 Jan 2015 19:56:11 +0000 (11:56 -0800)
Turns out path_relative_from returns Some even if they're not ancestors of one
another! This adds an explicit check for `is_ancestor_of`.

src/cargo/ops/cargo_rustc/mod.rs

index 95b492634f6a9957fa210f4cd6285fe47d1e7407..a61fddb365b467d37a6d4c392dac0b368fe8f733 100644 (file)
@@ -631,7 +631,12 @@ fn rustdoc(package: &Package, target: &Target,
 // absolute paths instead of relative paths.
 fn root_path(cx: &Context, pkg: &Package, target: &Target) -> Path {
     let absolute = pkg.get_root().join(target.get_src_path());
-    absolute.path_relative_from(cx.config.cwd()).unwrap_or(absolute)
+    let cwd = cx.config.cwd();
+    if cwd.is_ancestor_of(&absolute) {
+        absolute.path_relative_from(cwd).unwrap_or(absolute)
+    } else {
+        absolute
+    }
 }
 
 fn build_base_args(cx: &Context,